/**
 * FlyWeightFactory.java is created by Zachariah at 2012-2-1 下午12:24:04
 */
package com.zack.designPattern.flyweight;

import java.util.HashMap;
import java.util.Map;

/**
 * @author zachariah zzcfrog@gmail.com
 *
 */
public class FlyWeightFactory {
	
	private Map<String,FlyWeightMenu> menues ;
	
	public FlyWeightFactory(){
		this.menues = new HashMap<String, FlyWeightMenu>();
	}
	
	public FlyWeightMenu getMenu(String name){
		FlyWeightMenu menu = menues.get(name);
		if(menu == null){
			menu = new SharedFlyWeightMenu(name);
			menues.put(menu.getName(), menu);
		}
		return menu;
	}

}
